/*
 * 作者:熊猫
 * 日期:2017 - 3 - 20 10 - 27 - 21
 *
 */

package net.lainiao.morethread.Chapter8.demo2;

import java.util.concurrent.Phaser;
import java.util.concurrent.TimeUnit;

/**
 * Created by Administrator on 2017/3/20.
 */
public class Main {
    public static void main(String[] args) throws InterruptedException {
        Phaser phaser=new Phaser(3);
        for (int i = 0; i < 3; i++) {
            Task task=new Task(i+1,phaser);
            Thread thread=new Thread(task);
            thread.start();
        }
        for (int i = 0; i < 10; i++) {
            System.out.println("*****************************************");
            System.out.println("Main:Phaser Log");
            System.out.println("Main:Phaser:Phase:"+phaser.getPhase());
            System.out.println("Main:Phaser:Registered Parties:"+phaser.getRegisteredParties());
            System.out.println("Main:Phaser:Arrived Parties:"+phaser.getArrivedParties());
            System.out.println("Main:Phaser:Unarrived Parties:"+phaser.getUnarrivedParties());
            System.out.println("*****************************************");
            TimeUnit.SECONDS.sleep(1);
        }
        System.out.println("Main Over ");
    }
}
